/****************************************************************************
 *
 * Copyright (C) 2003-2008 Los Alamos National Security, LLC
 *                         Packet Analytics Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2 as
 * published by the Free Software Foundation.  You may not use, modify or
 * distribute this program under any other version of the GNU General
 * Public License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 ****************************************************************************/
package nfse.misc;
import java.util.*;

public class MetadataEntryStatus implements Comparable<MetadataEntryStatus> {

	public String date = "";
	int month = -1;
	int day = -1;
	int year = -1;
	int run = -1;
	int sensor = -1;
	boolean hasDataInfo = false;
	private Vector indexedFields = new Vector();

	public MetadataEntryStatus() {
	}
	
	public int compareTo(MetadataEntryStatus mes) {
		try {
			int val = getDateString().compareTo(mes.getDateString());
			if (val != 0)
				return val;
			if (mes.run == run)
				return 0;
			if (mes.run < run)
				return 1;
		} catch (Exception E) {
			E.printStackTrace();
		}
		return -1;
	}
	
	public String getDateString() {
		String temp = "" + year;
		if (month < 10)
			temp += "0";
		temp += "" + month;
		if (day < 10)
			temp += "0";
		temp += "" + day;
		return temp;
	}
	
	public void addIndexedField(int field) {
		indexedFields.addElement(new Integer(field));
	}
	
	public int[] getIndexedFields() {
		int[] fields = new int[indexedFields.size()];
		for (int i = 0; i < fields.length; i++) {
			fields[i] = ((Integer)indexedFields.elementAt(i)).intValue();	
		}
		return fields;
	}
	
	public String toString() {
	    StringBuilder temp = new StringBuilder();
		temp.append(date + ", ");
		temp.append(run + ", ");
		temp.append(hasDataInfo + ", ");
		int[] fields = getIndexedFields();
		for (int i = 0; i < fields.length; i++)
			temp.append(fields[i] + ", ");
		temp.append(month + ", ");
		temp.append(day + ", ");
		temp.append(year + "");
		
		return temp.toString();
	}
}